/*
 * Logging.java
 *
 * Created on 21 October 2007, 12:59
 *
 */

package net.ubinow.mflex.util;

/**
 *
 * @author Josh
 */
public class Logging {
    
    public static final int LOG_LEVEL_ERRORS   = 0;
    public static final int LOG_LEVEL_DEBUG    = 1;
    public static final int LOG_LEVEL_INFO     = 2;
    
    
    private int _logLevel = LOG_LEVEL_INFO; 
    
    //<editor-fold defaultstate="collapsed" desc="singleton field and method">
    private static Logging _instance = null;
    
    public static Logging getInstance(){
        if( _instance == null )
            _instance = new Logging(); 
        
        return _instance; 
    }
    //</editor-fold>
    
    private Logging() {
    }
    
    public void setLogLevel( int level ){
        _logLevel = level; 
    }
    
    synchronized public void trace( int level, String msg ){
        if( level <= _logLevel ){
            if( level == LOG_LEVEL_DEBUG ){
                System.out.println("DEBUG :: " + msg );
            }
            else if( level == LOG_LEVEL_ERRORS ){
                System.out.println("ERROR :: " + msg );
            }
            else if( level == LOG_LEVEL_INFO ){
                System.out.println("INFO :: " + msg );
            }
        }            
    }   
    
}
